/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.unipar.cursoweb.service;

import br.com.unipar.cursoweb.modelo.Cliente;
import br.com.unipar.cursoweb.modelo.OrdemServico;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

/**
 *
 * @author Thiago
 */
@Service("ordemServicoService")
public class OsServiceImpl extends GenericServiceImpl<OrdemServico> implements OsService {

    @Override
    public List<OrdemServico> consultar() {
        Criteria crit = ((Session) entityManager.getDelegate()).createCriteria(OrdemServico.class);

        return crit.list();
    }

    @Override
    public List<Cliente> consultarCliente(String cpf) {
        Criteria crit = ((Session) entityManager.getDelegate()).createCriteria(Cliente.class);
        if (cpf != null) {
            crit.add(Restrictions.ilike("cpf", cpf));
        }

        return crit.list();
    }
}
